// 基于 SnowLang Project (https://gitee.com/jcnc-org/snow) 的衍生作品
// 原始版权归属: Copyright © 2025 Ke Xu (Luke)
// 本实现版权归属: Copyright © 2025 Sany
// 遵循 Apache License 2.0 授权
package module

import "fmt"

/**
 * Represents metadata about the current method invocation for debugging purposes.
 * <p>
 * This class holds information about the method name and its arguments, which can be useful for debugging
 * and tracking method invocations in the virtual machine context. If no arguments are provided, an empty list
 * is used to avoid null references.
 * </p>
 *
 * @param methodName The name of the method being invoked.
 * @param arguments  The list of arguments passed to the method. If null, an empty list is used.
 */
type MethodContext struct {
	methodName string
	arguments  []interface{}
}

/**
 * Constructs a new MethodContext with the provided method name and arguments.
 * If the provided arguments are null, an empty list is used instead.
 *
 * @param methodName The name of the method being invoked.
 * @param arguments  The list of arguments passed to the method. If null, an empty list is used.
 */
func NewMethodContext(methodName string, arguments []interface{}) *MethodContext {
	if arguments == nil {
		arguments = make([]interface{}, 0)
	}
	return &MethodContext{
		methodName: methodName,
		arguments:  arguments,
	}
}

func (m *MethodContext) MethodName() string {
	return m.methodName
}

func (m *MethodContext) Arguments() []interface{} {
	return m.arguments
}

/**
 * Returns a string representation of the method invocation.
 * The format is: "Method: {methodName}, Args: {arguments}"
 *
 * @return A string representation of the method invocation, including its name and arguments.
 */

func (m *MethodContext) String() string {
	return fmt.Sprintf("Method: %s, Args: %v", m.methodName, m.arguments)
}
